<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="../css/mui.css" />
		<link rel="stylesheet" href="../css/style.css" />
		<script type="text/javascript" src="../js/jquery-1.8.0.min.js" ></script>
		<script type="text/javascript" src="../js/mui.min.js" ></script>
		<script type="text/javascript" src="../js/head_public.js" ></script>
		<script type="text/javascript" src="../js/common.js" ></script>
		<script type="text/javascript" src="../js/session.js" ></script>
	</head>
	<body>
		<div class=" login-container" id="login-container" style="overflow: auto;padding-bottom: 50px;">
		<!--<div class="login-container-regiest login-container" id="login-container">-->
			<form class="login-form" id="form">
				<div class="touxiang-zhuce">
					<img src="../images/zhuce-touxiang.png" class="touxiang-zhuce-img"/>
					<img src="../images/inputfile.png" class="input-icon"/>
					<!--<input type="file" name="touxiang" id="touxiang"  accept="image/*" capture="camera">-->
				</div>
				<p><input type="text"  name="member_name" placeholder="请输入用户名"/><img src="../images/login-icon1.png"></p>
				<p><input type="text"  name="idcard" placeholder="请输入身份证号"/><img src="../images/shenfen.png"></p>
				<p><input type="text"  name="member_mobile" id="mobile" placeholder="请输入手机号"/><img src="../images/shouji.png"></p>
				<p class="yanzheng"><input type="text" name="sms_captcha" placeholder="请输入验证码"/><button id="yzm" type="button">验证码</button><img src="../images/login-icon2.png"></p>
				<input type="hidden" id="true_yanzheng" name="true_captcha" />
				<input type="hidden" id="true_mobile" name="true_mobile" />
				<p><input type="password" class="newpass" name="member_password" placeholder="设置密码"/><img src="../images/login-icon3.png"></p>
				<p><input type="password" class="confirmpass" name="member_password_confirm" placeholder="确认密码"/><img src="../images/login-icon4.png"></p>
				<div class="go-login-div"><a data-href="login.html">去登录</a><a data-href="forgetpass.html">忘记密码？</a></div>
				<div class="sub-btn"><button type="button" class="submit">确定</button></div>
				<div style="color: #fff;font-size: 12px;width: 80%;margin: auto;">
					点击上面的注册按钮即表示您同意<a data-href="xieyi.html">《用户同意协议》</a>
				</div>
			
			</form>
		</div>
		<script>
			var t =59;
			// 验证码获取倒计时
			mui("#form").on("tap","#yzm",function(){
			 // 检查手机号格式
			  disableBtn(this);
			  var username =/^1[0-9]{10,10}$/;
			  var phone=$("#mobile").val();
			  if(phone==null||phone==''){
			    alert("手机号不能为空");
			    return false;
			  }else if(!username.test(phone)){
			    alert("手机号格式不正确");
			    return false;
			  }
			  
			  $(this).css("background-color","#999");
			  var yan_param = {};  //register
			  // Checkphone			
			  yan_param.sms_mobile = phone;
			  yan_param.type = "1";
			  // 判断返回值
			  $.post(net+"/public/index.php?s=api/login/get_captcha",yan_param,function(res){
			  	  if (res.code=="200") {
			  	  	$("#true_yanzheng").val(res.result.sms_captcha)
			  	  	$("#true_mobile").val(res.result.sms_mobile)
					$("#yzm").attr("disabled","disabled");
					$("#yzm").css({"background-color":"#999","border-color":"#999"});
				  	var inter=setInterval("refer()",1000); //启动1秒定时
				  }else {
				    alert(res.message);
				  }
			  }) 
			})
			var t=59;
			function refer()
			{
			  if(t==0)
			  {
			    $("#yzm").prop("disabled",false);//取消禁用
			    $("#yzm").css({"background-color":"#ff7e00","border-color":"#ff7e00","font-size":"12px"});
			    $("#yzm").html("验证码");
			  }else{
			    $("#yzm").html("验证码"+t+"s");
			    t--; // 计数器递减
			  }
			}
		$(function() {
			mui("body").on("tap","a",function(){
				mui.openWindow({
					url:$(this).attr("data-href")
				})
			})
			mui("body").on("tap",".submit",function(){				
	        	var $phone =/^1[0-9]{10,10}$/;
	        	var $passwd = /^\w{6,12}$/;
	            var params = $("#form").serializeObject();//将表单序列化为JSON对象
	            if(params.member_name==""||params.member_name==null){
	            	alert("请填写用户名！")
	            	return false;
	            }if(params.member_mobile==""||params.member_mobile==null){
	            	alert("请填写手机号！")
	            	return false;
	            }else if(!$phone.test(params.member_mobile)){
				    alert("请填写正确的手机号！");
				    return false;
				}else if(params.sms_captcha==""||params.sms_captcha==null){
				   alert("验证码不能为空！") 
				   return false;
				}else if(params.member_password==""||params.member_password==null){
					alert("新密码不能为空！");
					return false;
				}else if(!$passwd.test(params.member_password)){
					alert("新密码为6-12字母或者数字！")
					return false;
				}else if(params.member_password_confirm==""||params.member_password_confirm==null){
	            	alert("确认密码为空！")
	            	return false;
	            }else if(!$passwd.test(params.member_password_confirm)){
	            	alert("确认密码格式不正确！")
	            	return false;
	            }else if(params.member_password!=params.member_password_confirm){
	            	alert("两次密码不一致")
	            	return false;
	            }
	            $.post(net+"/public/index.php?s=api/login/register",params,function(res){
	            	if(res.code=="200"){
	            		alert("注册成功")
	            		
            			addCookie("userid",res.result.member_id,7);
						addCookie("username",res.result.member_name,7);
						addCookie("work",res.result.member_work,7);
						addCookie("workid",res.result.work_id,7);
	            		location.href="index.html";
	            	}else{
	            		alert(res.message)
	            	}
	            })
	        })  
	    });
	    $.fn.serializeObject = function() {  
	        var o = {};  
	        var a = this.serializeArray();  
	        $.each(a, function() {  
	            if (o[this.name]) {  
	                if (!o[this.name].push) {  
	                    o[this.name] = [ o[this.name] ];  
	                }  
	                o[this.name].push(this.value || '');  
	            } else {  
	                o[this.name] = this.value || '';  
	            }  
	        });  
	        return o;  
	    }
		</script>
		
	</body>
</html>
